/*
 * @Author: RYPY
 * @Date: 2021-02-23 09:17:59
 * @LastEditors: RYPY
 * @LastEditTime: 2021-02-23 09:24:08
 */
const mysql=require("mysql");
const dbConfig={
    host:"localhost",
    port:3306,
    user:"root",
    password:"123456",
    database:"u_course"
}
const db=mysql.createConnection(dbConfig);
db.connect();
//定义一个方法，执行sql
function query(sql){
    return new Promise(resolve=>{
       db.query(sql,(err,result)=>{
            if(err){
                resolve([err]);
            }else{
                resolve([null,result]);
            }
       }); 
    });
}
module.exports={query};